<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="string" uri="http://jakarta.apache.org/taglibs/string-1.1" %>
<%@ taglib uri="/WEB-INF/tlds/pagination.tld" prefix="pagination" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<html>
<head>
    <title>Bettersoft Portal</title>
    <link href="/common/css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">
        // 페이지 이동을 처리한다.
        function goListPage(page) {
            var TheForm = document.frm;
            TheForm.currentPage.value = page;
            TheForm.nextTarget.value = 'communityBoardList';
            TheForm.action = './communityBoardList.do';
            TheForm.submit();
        }

        // 검색어로 리스트를 출력한다.
        function jsSearchList() {
            var TheForm = document.frm;
            TheForm.title.value = TheForm.search_title.value;
            TheForm.writer_id.value = TheForm.search_writer.value;
            TheForm.writer_nick_name.value = TheForm.search_nickName.value;
            TheForm.content.value = TheForm.search_content.value;
            TheForm.nextTarget.value = 'communityBoardList';
            TheForm.action = './communityBoardList.do';
            TheForm.submit();
        }

        // 글쓰기 페이지로 이동 : 세션이 존재할 때만 가능
        function jsWriteBoard() {
            var TheForm = document.frm;
            TheForm.nextTarget.value = 'communityBoardWrite';
            TheForm.action = './communityBoardWrite.do';
            TheForm.submit();
        }

        // 게시물 보기 페이지로 이동
        function jsContentView() {
            var TheForm = document.frm;
            TheForm.nextTarget.value = 'communityBoardContent';
            TheForm.action = './communityBoardContent.do';
            TheForm.submit();
        }

        // Community Board List 페이지로 이동한다.
        function jsCommunityBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "communityBoardList";	// page name
            TheForm.action = "./communityBoardList.do";
            TheForm.submit();
        }

        // Photo Board List 페이지로 이동한다.
        function jsPhotoBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "photoBoardList";	// page name
            TheForm.action = "./photoBoardList.do";
            TheForm.submit();
        }

        // Notice Board List 페이지로 이동한다.
        function jsNoticeBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "noticeBoardList";	// page name
            TheForm.action = "./noticeBoardList.do";
            TheForm.submit();
        }

        // Contact Us 페이지로 이동한다.
        function jsContactUs() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "contactus";	// page name
            TheForm.action = "./contactus.do";
            TheForm.submit();
        }

        // FAQ 페이지로 이동한다.
        function jsFAQ() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "faq";	// page name
            TheForm.action = "./faq.do";
            TheForm.submit();
        }

        function jsBoardContent(boardno){
            var TheForm = document.frm;
            TheForm.boardno.value = boardno;
            TheForm.token.value = boardno;
            TheForm.nextTarget.value = 'communityBoardContent';
            TheForm.action = './communityBoardContent.do';
            TheForm.submit();
        }

    </script>
</head>

<body>
<div id="wrapper">
    <!------------------------------ top 시작-------------------------------------->
    <%@include file="portalHeader.jsp" %>
    <!------------------------------ top 끝-------------------------------------->
    <div class="sub_content">
        <form name="frm" method="POST">
            <input type="hidden" name="community_board_no" value="">
            <input type="hidden" name="title" value="${param.search_title}">
            <input type="hidden" name="writer_id" value="${param.search_writer}">
            <input type="hidden" name="writer_nick_name" value="${param.search_nickName}">
            <input type="hidden" name="content" value="${param.search_content}">
            <input type="hidden" name="nextTarget" value="">

            <input type="hidden" name="boardno" value="">
            <input type="hidden" name="page" value="${currentPage}">
            <input type="hidden" name="token" value="">

            <input type="hidden" name="currentPage" value="${currentPage}">
            <img src="/images/intro/sub_title03.gif" />
            <table class="notice_tb">
                <tr>
                    <td width="7%" class="notice_tb_headfirst"><spring:message code="communityBoardList.no" /></td>
                    <td width="58%" class="notice_tb_head"><spring:message code="communityBoardList.title" /></td>
                    <td width="10%" class="notice_tb_head"><spring:message code="communityBoardList.writer_id" /></td>
                    <td width="6%" class="notice_tb_head"><spring:message code="communityBoardList.vote" /></td>
                    <td width="6%" class="notice_tb_head"><spring:message code="communityBoardList.hitcount" /></td>
                    <td width="13%" class="notice_tb_headlast"><spring:message code="communityBoardList.register_date" /></td>
                </tr>
                <c:set var="totalCount" value="${totalRow}"/>
                <c:forEach items="${boardList}" var="boardList" varStatus="serviceStatus" begin="0" end="20"
                           step="1">

                    <tr>
                        <td class="notice_tb_list">${boardList.community_board_no}</td>
                        <!-- <td class="notice_tb_title"><a href="./communityBoardContent.do?boardno=boardList.community_board_no&page=currentPage&title&writer_id&writer_nick_name&content"> -->
                        <td class="notice_tb_title"><a href="javascript:jsBoardContent(${boardList.community_board_no})">${boardList.title}
                            <c:if test="${boardList.reply_count > 0}">
                                <font size="1">[${boardList.reply_count}]</font>
                            </c:if> <!-- 댓글 존재시 -->
                        </a></td>
                        <td class="notice_tb_list">${boardList.writer_id}</td>
                        <td class="notice_tb_list">${boardList.vote}</td>
                        <td class="notice_tb_list">${boardList.hitcount}</td>
                            <%--<td class="notice_tb_list">${boardList.register_date}</td>--%>
                        <td class="notice_tb_list">${boardList.date_part_year}<spring:message code="communityBoardList.year" />${boardList.date_part_month}<spring:message code="communityBoardList.month" />${boardList.date_part_day}<spring:message code="communityBoardList.day" />${boardList.date_part_hour}:${boardList.date_part_minute}</td>
                    </tr>
                </c:forEach>
                <!--
                <tr>
                    <td class="notice_tb_list">1</td>
                    <td class="notice_tb_title"><a href="#">더욱 상세한 그래프를 제공하는 My Page 서비스가 오픈됩니다.</a></td>
                    <td class="notice_tb_list"><a href="#">dayve</a></td>
                    <td class="notice_tb_list">3</td>
                    <td class="notice_tb_list">200</td>
                    <td class="notice_tb_list">2012-04-03 16:13:11</td>
                </tr>
                -->
            </table>
            <!---------------------------------------- 버튼 -------------------------------------->
            <!-- HttpSession 이 존재하지 않을 경우 글쓰기 버튼 팝업 안됨-->
            <% if(null == s.getAttribute("userId")){  %>

            <% }else{ %>

            <div class="btn_right">
                <a href="javascript:jsWriteBoard()"><img src="/images/intro/btn_write.gif" /></a>
            </div>
            <% } %>

            <div class="btn_left">
                <a href="javascript:jsCommunityBoardList()"><img src="/images/intro/btn_list.gif" /></a>
            </div>
            <!------------------------------------ 검색 ----------------------------------------->
            <div class="content_center">
                <pagination:paging>
                    <pagination:function>goListPage</pagination:function> <!-- 자바스크립트 함수 -->
                    <pagination:currentPage>${currentPage}</pagination:currentPage> <!-- 현재페이지 -->
                    <pagination:totalRows>${totalRow}</pagination:totalRows> <!-- 전체글수 -->
                    <pagination:pageSize>${pageSize}</pagination:pageSize> <!-- 페이지당 조회건수 -->
                </pagination:paging>
                <!--
                <img src="/images/intro/btn_first.gif" class="tb_btn" />
                <img src="/images/intro/btn_prev.gif" class="tb_btn" />
                1 2 3 4 5
                <img src="/images/intro/btn_next.gif" class="tb_btn" />
                <img src="/images/intro/btn_last.gif" class="tb_btn" />
                -->
            </div>
            <!-------------------------------------- 검색 끝 -------------------------------------->
            <table class="search_tb">
                <tr>
                    <td >&nbsp;</td>
                    <td width="16%" class="search_text">Title :</td>
                    <td width="16%" class="search_text">Writer :</td>
                    <td width="16%" class="search_text">Nickname : </td>
                    <td width="16%" class="search_text">Content :</td>
                    <td width="22%" class="search_text">&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="text" name="search_title" class="notice_input" value="${param.search_title}"/></td>
                    <td><input type="text" name="search_writer" class="notice_input" value="${param.search_writer}"/></td>
                    <td><input type="text" name="search_nickName" class="notice_input" value="${param.search_nickName}"/></td>
                    <td><input type="text" name="search_content" class="notice_input" value="${param.search_content}"/></td>
                    <td><a href="javascript:jsSearchList()"><img src="/images/intro/btn_search.gif"  /></a></td>
                </tr>
            </table>
        </form>
    </div>
    <!------------------------------ 하위메뉴 시작-------------------------------------->
    <%@include file="portalFooter.jsp" %>
    <!------------------------------ 하위메뉴 끝-------------------------------------->

</div>
</body>
</html>
